<template>
	<view class="box screen-all flex">
		<head-navigation></head-navigation>
		<view class="content-view flex">
			<view class="flex row aCenter">
				<text>姓名:</text>
				<input v-model="bank_username" placeholder="请输入" />
			</view>
			<view class="flex row aCenter">
				<text>银行卡号:</text>
				<input v-model="bank_number" type="number" placeholder="请输入" />
			</view>
			<view class="flex row aCenter">
				<text>开户行:</text>
				<input v-model="bank_name" placeholder="请输入" />
			</view>
		</view>
		
		<view class="btn-view flex center" @click="submit">
			保存
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				balance: '',
				bank_name: '',
				bank_number: '',
				bank_username: '',
				id: '',
			}
		},
		onLoad() {
			this.getInfo();
		},
		methods: {
			getInfo  () {
				// api/Talent/withdrawal
				let params = {
					token: uni.getStorageSync("token"),
				}
				console.log(params);
				this.$request("api/Talent/withdrawal", params)
					.then(({ code, msg, data, time }) => {
						console.log(code, msg, data);
						if(code == 1){
							this.balance = data.balance;
							this.bank_name = data.bank_name;
							this.bank_number = data.bank_number;
							this.bank_username = data.bank_username;
							this.id = data.id;
						}else{
							
						}
					}).catch((e) => {
						console.log(e);
					});
			},	
			submit () {
				if(!this.bank_username){
					uni.showToast({
						title: '请输入姓名', icon: 'none',
					})
					return ;
				}
				if(!this.bank_number){
					uni.showToast({
						title: '请输入银行卡号', icon: 'none',
					})
					return ;
				}
				if(!this.bank_name){
					uni.showToast({
						title: '请输入开户行', icon: 'none',
					})
					return ;
				}
				
				let params = {
					token: uni.getStorageSync("token"),
					bank_name: this.bank_name,
					bank_number: this.bank_number,
					bank_username: this.bank_username,
				}
				console.log(params);
				this.$request("api/Talent/binding_bank", params)
					.then(({ code, msg, data, time }) => {
						console.log(code, msg, data);
						uni.showToast({
							title: msg, icon: 'none',
						})
						if(code == 1){
							uni.navigateBack();
						}else{
							
						}
					}).catch((e) => {
						console.log(e);
					});
			}
		}
	}
</script>

<style scoped lang="scss">
	.box {
		background-color: #F3F3F3;
	}
	.content-view {
		width: 700rpx;
		min-height: 200rpx;
		margin: 20rpx auto;
		background-color: #FFF;
		border-radius: 20rpx;
		view {
			height: 100rpx;
			border-bottom: 1rpx solid #EFEFEF;
			margin: 0 30rpx;
		}
		text {
			width: 170rpx;
			font-size: 28rpx;
			color: #010B24;
			margin-right: 10rpx;
		}
		input {
			font-size: 28rpx;
		}
	}
	.btn-view {
		width: 700rpx;
		height: 106rpx;
		margin-right: 25rpx;
		background-color: #010B24;
		border-radius: 53rpx;
		font-size: 28rpx;
		color: #FFF;
		position: absolute;
		bottom: 100rpx;
		left: 25rpx;
		&:active {
			background-color: #010B24EE;
		}
	}
</style>
